package com.ibigcat.module.mdm.dao.mapper;

import java.util.*;

import com.ibigcat.framework.common.pojo.PageResult;
import com.ibigcat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ibigcat.framework.mybatis.core.mapper.BaseMapperX;
import com.ibigcat.module.mdm.dao.entity.CommodityDO;
import org.apache.ibatis.annotations.Mapper;
import com.ibigcat.module.mdm.controller.admin.commodity.vo.*;

/**
 * 商品信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CommodityMapper extends BaseMapperX<CommodityDO> {

    default PageResult<CommodityDO> selectPage(CommodityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommodityDO>()
                .likeIfPresent(CommodityDO::getSkuName, reqVO.getSkuName())
                .eqIfPresent(CommodityDO::getCustomerSkuCode, reqVO.getCustomerSkuCode())
                .eqIfPresent(CommodityDO::getIotSkuCode, reqVO.getIotSkuCode())
                .eqIfPresent(CommodityDO::getFactorySkuCode, reqVO.getFactorySkuCode())
                .likeIfPresent(CommodityDO::getIotSkuName, reqVO.getIotSkuName())
                .eqIfPresent(CommodityDO::getSkuBrand, reqVO.getSkuBrand())
                .eqIfPresent(CommodityDO::getSkuUnit, reqVO.getSkuUnit())
                .eqIfPresent(CommodityDO::getCustomerCode, reqVO.getCustomerCode())
                .eqIfPresent(CommodityDO::getCustomizedInd, reqVO.getCustomizedInd())
                .eqIfPresent(CommodityDO::getLength, reqVO.getLength())
                .eqIfPresent(CommodityDO::getWidth, reqVO.getWidth())
                .eqIfPresent(CommodityDO::getHeight, reqVO.getHeight())
                .eqIfPresent(CommodityDO::getGrossWeight, reqVO.getGrossWeight())
                .eqIfPresent(CommodityDO::getVolume, reqVO.getVolume())
                .eqIfPresent(CommodityDO::getFirstCategoryLevel, reqVO.getFirstCategoryLevel())
                .eqIfPresent(CommodityDO::getSecondCategoryLevel, reqVO.getSecondCategoryLevel())
                .eqIfPresent(CommodityDO::getThirdCategoryLevel, reqVO.getThirdCategoryLevel())
                .eqIfPresent(CommodityDO::getDisabled, reqVO.getDisabled())
                .eqIfPresent(CommodityDO::getDataSource, reqVO.getDataSource())
                .betweenIfPresent(CommodityDO::getReferenceTime, reqVO.getReferenceTime())
                .eqIfPresent(CommodityDO::getReferencePrice, reqVO.getReferencePrice())
                .betweenIfPresent(CommodityDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CommodityDO::getId));
    }

}